<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateWalletReatedTable extends Migration {

	/**
	 * Run the migrations.
	 *
	 * @return void
	 */
	public function up()
	{
		Schema::create('wallet', function(Blueprint $table){
			$table->integer('user_id')->unique();
			$table->decimal('money', 11, 2);
			$table->timestamps();
		});
		// 交易表，记录钱包的流水
		Schema::create('wallet_transactions', function(Blueprint $table){
			$table->increments('id');
			$table->integer('user_id');
			$table->string('type', 20)->nullable()->defaults('');	// 类型
			$table->enum('direction', array('out', 'in'))->nullable()->defaults('');	// 方向
			$table->integer('associate_id');						// 关联的id，不同的类型会对应不同的关联id
			$table->enum('status', array('success', 'fail', 'wait'))->nullable()->defaults('');		// 状态
			$table->timestamps();
		});
	}

	/**
	 * Reverse the migrations.
	 *
	 * @return void
	 */
	public function down()
	{
		//
	}

}
